﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using LoginServer.Manager;
using LoginServer.Networking.Packets;

namespace LoginServer.Networking.Handlers
{
    class SHANDLE_AUTH_SERVER : PacketHandler
    {
        public override void Handle(LoginServer.Virtual_Objects.Server.virtualServer Server)
        {
            string Password = getNextBlock();
            if (Password == Program.ServerKey)
            {
                string nullObj = getNextBlock();
                string strName = getNextBlock();
                string strIP = getNextBlock();

                Server.setup(strName, strIP);

                if (ServerManager.addServer(Server))
                {
                    Server.send(new SPACKET_AUTH_SERVER(Server));
                }
            }
            else
            {
                Server.send(new SPACKET_AUTH_SERVER());
                Server.disconnect();
            }
        }
    }
}
